import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RoomMemberVO, RoomMemberForm, RoomMemberQuery } from '@/api/dormitory/roomMember/types';

/**
 * 查询宿舍人员列表
 * @param query
 * @returns {*}
 */

export const listRoomMember = (query?: RoomMemberQuery): AxiosPromise<RoomMemberVO[]> => {
  return request({
    url: '/dormitory/roomMember/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询宿舍人员详细
 * @param id
 */
export const getRoomMember = (id: string | number): AxiosPromise<RoomMemberVO> => {
  return request({
    url: '/dormitory/roomMember/' + id,
    method: 'get'
  });
};

/**
 * 新增宿舍人员
 * @param data
 */
export const addRoomMember = (data: RoomMemberForm) => {
  return request({
    url: '/dormitory/roomMember',
    method: 'post',
    data: data
  });
};

/**
 * 修改宿舍人员
 * @param data
 */
export const updateRoomMember = (data: RoomMemberForm) => {
  return request({
    url: '/dormitory/roomMember',
    method: 'put',
    data: data
  });
};

/**
 * 删除宿舍人员
 * @param id
 */
export const delRoomMember = (id: string | number | Array<string | number>) => {
  return request({
    url: '/dormitory/roomMember/' + id,
    method: 'delete'
  });
};
